<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/web/common.jsp" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>派单</title>
<script src="${ctx}/assets/js/jquery.js" type="text/javascript"></script>

</head>
<body>
	<input type="text" id="address" name="address"/>
	<input type="button" id="btn" name="btn" value="派单"/> <br/>
	<input type="text" id="storeId" name="storeId"/><br/>
	<span id="result"></span>
	<script type="text/javascript">
		var storeId1,storeId2,storeId3;
		$("#btn").click(function(){
			//alert("123");
			$.post("${ctx}/porderyb",{"address":$('#address').val()},function(data){
				for(var i=0;i<data.length;i++){
					//alert(data[i].id);
					$("#result").append("<li id='id"+i+"'>门店名字:"+data[i].storename+",距离:"+data[i].distance+"</li><br/>");
					if(i==0){
						storeId1=data[i].id;
					}
					if(i==1){
						storeId2=data[i].id;
					}
					if(i==2){
						storeId3=data[i].id;
					}
				}
				
			},"json");
		});
		$("#id0").live("click",function(){
			$("#storeId").val(storeId1);
		});
		$("#id1").live("click",function(){
			$("#storeId").val(storeId2);
		});
		$("#id2").live("click",function(){
			$("#storeId").val(storeId3);
		});
	</script>
</body>
</html>


